{extend name="base" /}
{block name="content"}
<script src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>


    <div class="m-main-content">
        <div class="m-container">
            <table class="m-table">
                <tr>
                    <th>
                        <div class="m-options cf">
                            <div class="m-search fr">
                                <form action="" class="layui-form">
                                    <label for="goods_name">商品名称</label>
                                    <input type="text" name="goods_name" id="goods_name" class="u-ipt u-ipt-def" placeholder="请输入要查询的名称" value="{$goods_name}" />
                                    <input type="submit" class="u-btn u-search" value="查看" />
                                </form>
                            </div>
                        </div>
                    </th>
                </tr>
            </table>
            <form class="layui-form m-list-form">
                <table class="m-table">
                    <tbody class="datas">
                    <tr>
                        <th width="5%" style="text-align: center;">选择</th>
                        <th width="5%">ID</th>
                        <th width="10%">商品名称</th>
                        <th width="10%">价格</th>
                        <th width="10%">库存</th>
                    </tr>
                    {foreach name="list" item="v"}
                    <tr>
                        <td align="center"><input type="radio" name="goods_id" class="u-id" value="{$v.id}" lay-skin="primary" /></td>
                        <td>{$v.id}</td>
                        <td>{$v.goods_name}</td>
                        <td>{$v.sale_price}</td>
                        <td>{$v.goods_stock}</td>
                    </tr>
                    {/foreach}
                    <tr>

                    </tr>
                    <tr>
<!--                        <td align="center"><input type="checkbox" value="1" lay-skin="primary" lay-filter="select_ids" /></td>-->
                        <td colspan="5" class="m-options"><span style="display: inline-block;
    padding: 3px 20px;
    background: #E7666D url(none);
    font-size: 13px;
    color: #fff;
    text-align: center;
    border: none;
    border-radius: 2px;
    -webkit-box-shadow: rgba(0, 0, 0, .117647) 0px 2px 6px, rgba(0, 0, 0, .239216) 0px 1px 2px;
    box-shadow: rgba(0, 0, 0, .117647) 0px 2px 6px, rgba(0, 0, 0, .239216) 0px 1px 2px;
    -webkit-transition: background .3s ease;
    transition: background .3s ease;
    cursor: pointer;"  id="submit">确定</span></td>
                    </tr>
                    </tbody>
                </table>
            </form>

            {include file="public:page" /}
        </div>
    </div>
{/block}{block name="extrajs"}
{include file="laypage" /}
<script>
    $(function(){
        layui.use('layer', function(){
            $('#submit').click(function(res){
                var goods_ids="";

                goods_ids=$("input[name='goods_id']:checked").val();

                if(goods_ids===""){
                    layer.msg("请选择车活动商品！");return false;
                }

                $.post('/manage/role_goods/saveGoods',{goods_id:goods_ids},function (res) {
                    if(res.code===1){
                        layer.msg(res.msg)
                        setTimeout(function () {
                            parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        },1500);
                    }else{
                        layer.msg(res.msg)
                    }
                })

            });
        })
    })</script>{/block}